<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">配套信息</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-form ref="form" :model="form" label-width="80px" :inline="true" size="mini">
                    <el-form-item label="承租人:">
                        <div style="width: 150px">
                            <el-input v-model="form.czr" placeholder="请输入承租人" @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="房屋地址:">
                        <div style="width: 150px">
                            <el-input v-model="form.fwdz" placeholder="请输入房屋地址" @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="档案编号:">
                        <div style="width: 150px">
                            <el-input v-model="form.dabh" placeholder="请输入档案编号" @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                        <el-button @click="reSearch" icon="el-icon-refresh" class="searchcolor">重置</el-button>
                    </el-form-item>
                </el-form>
            </div>
            <el-table
                :data="tableData"
                style="width: 100%"
                :header-cell-style="tableHeaderColor"
                :row-style="tablerowColor"
                :row-class-name="tableRowClassName"
                :cell-style="tablecellColor"
                border
                :max-height="maxHeight"
            >
                <!-- <el-table-column prop="htbh" label="合同编号" align="center" fixed width="160"> </el-table-column> -->
                <el-table-column prop="dabh" label="档案编号" align="center" fixed width="240" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="fwdz" label="房屋地址" align="center" width="280" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="czr" label="承租单位" align="center" width="280"> </el-table-column>
                <el-table-column prop="zjdj" label="租金单价" align="center"> </el-table-column>
                <el-table-column prop="qdsj" label="签订时间" align="center" width="120">
                    <template slot-scope="scope">
                        {{ scope.row.qdsj ? scope.row.qdsj.split(' ')[0] : '' }}
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="zlqssj" label="起租时间" align="center" width="120">
                        <template slot-scope="scope">
                            {{ scope.row.zlqssj ? scope.row.zlqssj.split(' ')[0] : '' }}
                        </template>
                    </el-table-column>
                    <el-table-column prop="zldqsj" label="到期时间" align="center" width="120">
                        <template slot-scope="scope">
                            {{ scope.row.zldqsj ? scope.row.zldqsj.split(' ')[0] : '' }}
                        </template>
                    </el-table-column> -->

                <el-table-column label="操作" width="100" align="center" fixed="right">
                    <template slot-scope="scope">
                        <el-button type="text" size="small" @click="gotodetail(scope.row)">详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination
                    background
                    layout="total,sizes,prev, pager, next,jumper"
                    :total="total"
                    :current-page.sync="current"
                    :page-size="pageSize"
                    @current-change="handleCurrentChange"
                    :page-sizes="[10, 20, 30, 40, 50, 100]"
                    @size-change="handleSizeChange"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { exportzjinfolist, zjinfoupdate, getsbsignlist } from '@/api/index';
export default {
    name: 'dalist',
    data() {
        return {
            newPhonenum: {
                id: '',
                lxdh: ''
            }, //新的电话
            editdialog: false,
            dialogVisible: true,
            radio: 3,
            total: 0,
            current: 1,
            pageSize: 10,
            form: {
                create_name: '', // 创建人
                create_name_id: '', // 创建人id ,
                create_time: '', // 创建时间 ,
                current: 1, // 第几页 ,
                czmj: '', // 出租面积 ,
                czr: '', //承租人 ,
                czrlxfs: '', //承租人联系方式 ,
                dabh: '', //档案编号 ,
                db: '', //电表 ,
                fj: '', //附件 ,
                fwdz: '', //房屋地址 ,
                glfs: '', //管理方式 出租经营 委托管理 ,
                htbh: '', //合同编号 ,
                htdqsj: '', //合同到期时间（签订时约定时间） ,
                htje: '', //合同金额 ,
                htzzsj: '', //合同中止时间 ,
                htzzyy: '', //合同中止原因 ,
                id: '', //id ,
                jmje: '', //减免金额 ,
                jmyy: '', //减免原因 ,
                lxdz: '', //联系地址 ,
                lxdh: '', //联系电话
                ndgrf: '', // 年度供热费 ,
                pageSize: 10, //每页数量 ,
                qdsj: '', //合同签订时间 ,
                relid: '', //关联ID ,
                rqb: '', //燃气表 ,
                rzfj: '', //入住附件 ,
                sbqd: '', //设备清单 ,
                shb: '', //水表 ,
                status_code: 1, //1正常 2删除 ,
                stdwid: '', //受托单位ID ,
                type: '', //分类 1:房间 2：楼栋 ,
                update_name: '', //修改人 ,
                update_name_id: '', //修改人id ,
                update_time: '', //修改时间 ,
                wyf: '', //物业费 ,
                yj: '', //押金 ,
                ysje: '', //预收金额 ,
                zjdj: '', //租金单价 ,
                zjhm: '', //证件号码 ,
                zjmc: '', //证件名称 ,
                zldqsj: '', //租赁到期时间（提前中止修改） ,
                zlqssj: '', //租赁起始时间 ,
                zlqx: '', //租赁期限 ,
                zlyt: '' //租赁用途
            },
            tableData: [],

            maxHeight: null
        };
    },
    components: {},
    computed: {
        // 判断变色
        getcolorred(htzt) {
            console.log(htzt);
            return (htzt) => {
                if (htzt == '正常') {
                    return { color: '#19BE6B', fontWeight: 700 };
                } else if (htzt == '已经到期') {
                    return { color: '#D9001B', fontWeight: 700 };
                } else if (htzt == '即将到期') {
                    return { color: '#FF9900', fontWeight: 700 };
                } else if (htzt == '未签合同') {
                    return { color: '#409ee1', fontWeight: 700 };
                }
            };
        }
    },
    methods: {
        // var data = datas.find((item) => item.id == "1"); 使用find方法找到数组中对应的对象
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background:linear-gradient(to bottom, #008A94,#0ae2f2)!important;color:#ffffff;font-size:14px;';
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;color:black';
        },
        tablecellColor() {
            return 'font-weight:700;color:#000000;border-color:#c0c0c0';
        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 != 0) {
                return 'success-row'; //这是类名
            } else {
                return '';
            }
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.form.pageSize = this.pageSize;
            this.getsbsignlist(this.form);
            console.log(val);
        },
        // 每页条数
        handleSizeChange(val) {
            this.current = 1;
            this.pageSize = val;
            this.form.pageSize = val;
            this.getsbsignlist(this.form);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.getsbsignlist(this.form);
            console.log('搜索');
        },
        // 重置
        reSearch() {
            this.current = 1;
            this.pageSize = 10;
            this.form = {
                create_name: '',
                create_name_id: '',
                create_time: '',
                current: 1,
                czdz: '',
                czmj: '',
                czr: '',
                czrlxfs: '',
                dabh: '',
                db: '',
                fj: '',
                fwdz: '',
                glfs: '',
                htbh: '',
                htdqsj: '',
                htje: 0,
                htzzsj: '',
                htzzyy: '',
                id: '',
                jmje: 0,
                jmyy: '',
                lxdz: '',
                lxdh: '',
                ndgrf: '',
                pageSize: 10,
                qdsj: '',
                relid: '',
                rqb: '',
                rzfj: '',
                sbqd: '',
                sbqk: '',
                shb: '',
                status_code: 0,
                stdwid: '',
                type: '',
                update_name: '',
                update_name_id: '',
                update_time: '',
                wyf: '',
                yj: 0,
                ysje: 0,
                zjdj: 0,
                zjhm: '',
                zjmc: '',
                zldqsj: '',
                zlqssj: '',
                zlqx: '',
                zlyt: ''
            };
            this.getsbsignlist(this.form);
            console.log('搜索');
        },
        // 项目列表
        getsbsignlist(data) {
            getsbsignlist(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        },
        // 编辑租金信息
        zjinfoupdate(data) {
            zjinfoupdate(data).then((res) => {
                if (res.code == 200) {
                    this.$message.success('修改成功！！！');
                } else {
                    this.$message.error('修改失败！！！');
                }
            });
        },
        // 跳转详情页
        gotodetail(e) {
            console.log('详情',e);
            let data=JSON.stringify(e)
            this.$router.push({
                name: 'fwjgfjdetail',
                query: { data: data }
            });
        }
    },
    mounted() {
        this.$nextTick(() => {
            // window.innerHeight 浏览器窗口的可见高度，下面的 420 是除了table最大高度的剩余空间。
            this.maxHeight = window.innerHeight - 440;
        });
        this.getsbsignlist(this.form);
    }
};
</script>

<style scoped>
/* 单选样式强制修改成纵向的*/
::v-deep .msgbox-card .el-radio {
    width: 90%;
    display: block;
    margin: 10px 0;
}
.container {
    /* height: calc(100vh - 260px); */
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}
</style>
<style>
.success-row {
    background-color: #eaf3fb !important;
}
</style>
